<?php if ( $this->canRoute( $this->route, 'create' ) ) { ?>
<a href="<?php echo $this->url(array(), $this->route->create); ?>">create</a>
<?php } ?>
<ul>
<?php
$last = null;

foreach( $this->data as $id => $row ) {
	if( $this->is_tree ) { 
		if ( $last && $last != $row ) {
			if ( $last['id'] == $row['pid'] ) { 
				echo '<ul>';
			} 
			if ( $last['level'] >= $row['level'] ) { 
				for($i=0; $i<($last['level']-$row['level']);$i++){
					echo '</ul>';
				} 
			}
		}
		$last = $row;
	}
	?><li><a href="<?php echo $this->url(array('id'=>$row['id']), $this->route->edit ); ?>"><?php echo isset($row['title']) ? $row['title'] : $row['name'] ?></a></li><?php
}
?>
</ul>
